﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufExtension.h"
#include "GnufQtObjectPtr.h"
#include <GnufPallet.h>

namespace gnuf {

    enum StrategyType
    {
        FAMILY_CREATE = 0,
        FAMILY_RENAME,
        FAMILY_OVERRIDE,
        FAMILY_IGNORE,
    };

    struct FamilyInfo
    {
        std::wstring    Name;
        std::wstring    FielPath;
        int             Count;
        StrategyType    Strategy;
    };

    class Table;
    class QtBnufLoadStrategySelector;

    class GNUF_EXTENSION_EXPORT GnufLoadStrategySelector final
        : public IPalletEventHandler
    {
        CANNOT_COPY_OR_ASSIGN(GnufLoadStrategySelector)
    public:
        explicit GnufLoadStrategySelector();
        ~GnufLoadStrategySelector();

        typedef std::vector<FamilyInfo> FamilyGroup;
        // 设置构件信息（弱引用）
        void setFamilies(FamilyGroup* families);
        FamilyGroup* Families() const;
        // 检查是否全部都被取消了
        bool IsAllIgnored();
        // 显示对话框
        bool Show();

    protected:
        // Inherits from IPalletEventHandler...
        virtual void onHeaderButtonClicked(Pallet *) override;
        virtual bool onFooterButtonClicked(Pallet *) override;
        virtual bool onKeyEvent(Pallet *, IPalletEventHandler::EKey) override;

    private:
        gcmp::QtAutoPtr<QtBnufLoadStrategySelector> m_qtSelector;
        bool m_resultCode;
        FamilyGroup* m_families;
    };
}
